

package server;

/**
 *
 * @author Muhammad Asad Ullah
 */
public class responseBuilder {

    /**
     *
     * @return - Invalid Response (Response String) in standard format.
     */
    public String invalidRequestResponse()
    {
        return "%%Operation=unknown%%status=fail";
    }

    /**
     *
     * @param parameters - Clients Access credentials.
     * @param status - Status of login operation.
     * @return - Response to be sent to Client as String.
     */
    public String LoginResponse(String [] parameters,Boolean status)
    {
        if(status)
        return "%%Operation=login%%status=success";
        else
            return "%%Operation=login%%status=fail";
    }
    /**
     * 
     * @param parameters - parameters parsed from clients request.
     * @return Logout response to be sent.
     */
    public String logoutResponse(String [] parameters)
    {
        return "%%Operation=logout%%status=success";
    }
    /**
     *
     * @param parameters
     * @param status
     * @return send message response
     */
    public String sendMessageResponse(String [] parameters,Boolean status)
    {
        if(status)
        return "%%Operation=sendmessage%%status=success";
        else
        return "%%Operation=sendmessage%%status=success";
    }
    /**
     *
     * @param parameters
     * @param status
     * @return Add user response.
     */
    public String AddUserResponse(String [] parameters,Boolean status)
    {
        if(status)
            return "%%Operation=adduser%%status=success";
        else
            return "%%Operation=adduser%%status=fail";
    }
    /**
     *
     * @param parameters
     * @param status
     * @return edit user response
     */
    public String EditUserResponse(String [] parameters,Boolean status)
    {
        if(status)
            return "%%Operation=edituser%%status=success";
        else
            return "%%Operation=edituser%%status=fail";
    }
    /**
     *
     * @param parameters
     * @param status
     * @return kick user response.
     */
    public String KickUserResponse(String [] parameters,Boolean status)
    {
        if(status)
            return "%%Operation=kickuser%%status=success";
        else
            return "%%Operation=kickuser%%status=fail";
    }
    /**
     *
     * @param parameters
     * @param status
     * @return delete user response.
     */
    public String deleteUserResponse(String [] parameters,Boolean status)
    {
         if(status)
            return "%%Operation=deleteuser%%status=success";
        else
            return "%%Operation=deleteuser%%status=fail";
    }
    /**
     *
     * @param parameters
     * @return userList Response
     */
    public String userListResponse(String [] parameters)
    {
        String response = "%%Broadcast=userlist%%";
        for(int i = 0;i < parameters.length;i++)
            response += parameters[i]+",";
        return response;
    }
    /**
     *
     * @param parameters
     * @return userList Broadcast
     */
    public String userListBroadCast(String [] parameters)
    {
        String response = "%%Broadcast=userlist%%";
        for(int i = 0;i < parameters.length;i++)
            response += parameters[i]+",";
        return response;
    }
  /**
   *
   * @param parameters
   * @return Message Broadcast
   */
    public String messageBroadCast(String [] parameters)
    {
        return "%%Broadcast=message%%"+parameters[0]+"%%"+parameters[1];
    }
    /**
     *
     * @param username
     * @return inactiveUserBroadcast
     */
    public String inactiveUserLogoutBroadCast(String username)
    {
        return "%%Broadcast=dcinactive%%username="+username;
    }
   /**
    *
    * @param username
    * @return kicked user warning broadcast
    */
    public String kickedUserWarning(String username)
    {
        return "%%Broadcast=kicked%%username="+username;
    }
    /**
     *
     * @param parameters
     * @return edited user warning broadcast
     */
    public String editedUserWarning(String [] parameters)
    {
        return "%%Broadcast=edited%%username="+parameters[0]+"%%newusername="
                + parameters[1]+"%%newpassword=" +parameters[2]+"%%superuser="+ parameters[3];
    }
    /**
     *
     * @param userName
     * @return delete user warning broadcast.
     */
    public String deletedUserWarning(String userName)
    {
        return "%%Broadcast=deleted%%username="+userName;
    }


}
